package com.zhaoqi.hr.service;

import com.zhaoqi.hr.dto.response.WorkerProfileResponse;
import com.zhaoqi.hr.entity.WorkerProfile;
import com.zhaoqi.hr.repository.WorkerProfileRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 劳动者档案服务
 */
@Service
public class WorkerProfileService {
    
    @Autowired
    private WorkerProfileRepository workerProfileRepository;
    
    /**
     * 根据ID获取劳动者档案
     */
    @Transactional(readOnly = true)
    public WorkerProfileResponse getWorkerById(Long id) {
        WorkerProfile workerProfile = workerProfileRepository.findByIdWithUser(id)
            .orElseThrow(() -> new RuntimeException("劳动者不存在"));
        
        return new WorkerProfileResponse(workerProfile);
    }
}
